﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Yugi.Client;

namespace Yugi_Gui.LayoutManager
{
    class LayoutManager
    {
        internal static Window MainWindow;
        private LayoutType current = LayoutType.Begin;
        static LayoutManager insitance;
        private LayoutManager()
        {

        }
        public static LayoutManager Insitance
        {
            get
            {
                if (insitance == null)
                    insitance = new LayoutManager();
                return insitance;
            }
        }


        public void ChangeToLayout(LayoutType type)
        {
            if (type != current)
            {
                current = type;
                LoadLayout();
            }
            else
            {
                Yugi.Client.IInvoke Iinvoke = (Yugi.Client.IInvoke)MainWindow.Content;
                Iinvoke.Refresh();
            }

        }

        public void LoadExistLayout(Game1Layout g)
        {
            MainWindow.Content = g;
        }

        public void ChangeRPSLayOut(SupervisorModel s , Game1Layout g , int id)
        {
            MainWindow.Content = new RPGLayout(s, g, id);
        }

        private void LoadLayout()
        {
            if (MainWindow == null)
                MessageBox.Show("Layout Manager Init False");
            switch (current)
            {
                case LayoutType.Login:
                    MainWindow.Content = null;
                    MainWindow.Content = new LoginLayout();
                    break;
                case LayoutType.Room:
                    MainWindow.Content = null;
                    MainWindow.Content = new RoomLayout();
                    break;
                case LayoutType.Deck:
                    MainWindow.Content = null;
                    MainWindow.Content = new DeckConstructLayout();
                    break;
                case LayoutType.PlayGame:
                    MainWindow.Content = null;
                    MainWindow.Content = new Game1Layout();
                    break;
                case LayoutType.Externa:
                    MainWindow.Content = null;
                    MainWindow.Content = new ExternalLayout();
                    break;
                case LayoutType.Yugiohvietnam:
                    MainWindow.Content = null;
                    MainWindow.Content = new Yugiohvietnam();
                    break;
                
                default:
                    break;
            }
        }
    }
    enum LayoutType
    {
        Begin,
        Login,
        Room,
        Deck,
        PlayGame,
        Externa,
        Yugiohvietnam,
        RPS
    }
}
